package com.forum.model.pojo;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
@Table(name = "subforum")
public class SubForum {
	
	@Id
	@Column(name = "name")
	private String name;
	
	@OneToMany(fetch = FetchType.EAGER)
	@Cascade(CascadeType.ALL)
	@JoinColumn(name = "subforumname")
	private List<Section> sections; 
	
	@Column(name = "moderator", nullable = false)
	private Long moderator;
	
	@Column(name = "sectioncount")
	private int sectionCount;
	
	@Column(name = "topiccount")
	private int topicCount;
	
	@Column(name = "postcount")
	private int postCount;
	
	@Column(name = "description", nullable = false)
	private String description;
	
	public SubForum() {this.sections = new ArrayList<Section>();}
	
	public SubForum(String description, Long moderator) {
		this.description = description;
		this.moderator = moderator;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Long getModerator() {
		return moderator;
	}

	public void setModerator(Long moderator) {
		this.moderator = moderator;
	}

	public int getSectionCount() {
		return sectionCount;
	}

	public void setSectionCount(int sectionCount) {
		this.sectionCount = sectionCount;
	}
	
	public List<Section> getSections() {
		return sections;
	}

	public int getTopicCount() {
		return topicCount;
	}

	public void setTopicCount(int topicCount) {
		this.topicCount = topicCount;
	}

	public int getPostCount() {
		return postCount;
	}

	public void setPostCount(int postCount) {
		this.postCount = postCount;
	}
}
